<template>
  <div class="container">
    <div class="weather-side">
      <div class="weather-gradient"></div>
      <div class="date-container">
        <h3 class="date-dayname">{{week }}</h3><span class="date-day">{{date}}</span>
      </div>
      <div class="weather-container">
        <h1 class="weather-temp">{{tem}}°C</h1>
        <h4 class="weather-desc">{{ wea }}</h4>
      </div>
      <span class="location">{{ city }}</span>
    </div>
  </div>
</template>

<script>

import axios from "axios";
export default {
  name: "Weather",
  data() {
    return {
      week: '',
      date: '',
      tem: '',
      wea: '',
      city: '',
    }
  },
  methods: {
    sendReq() {
      axios('https://v0.yiketianqi.com/free/day?appid=54912433&appsecret=GVwyD4pd&unescape=1',
          {withCredentials: false}
    ).then(resp=>{
        this.wea = resp.data.wea;
        this.week = resp.data.week;
        this.date = resp.data.date;
        this.tem = resp.data.tem;
        this.city = resp.data.city;

      })
      /*.then((response) => {
        console.log(response);//查看接口返回的数据
        this.wea = response.wea;//天气
        this.tem = response.tem;//温度
      })*/
    }
  },
  mounted() {
    this.sendReq();
  }
}
</script>

<style scoped>
.container {
  cursor: pointer;
  border-radius: 25px;
  -webkit-box-shadow: 0 0 70px -10px rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 70px -10px rgba(0, 0, 0, 0.2);
  color: #ffffff;
  height: 150px;
}

.weather-side {
  position: relative;
  height: 150px;
  border-radius: 25px;
  background-image: url("../../assets/img/bg_weather.jpg");
  width: 150px;
  -webkit-box-shadow: 0 0 20px -10px rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 20px -10px rgba(0, 0, 0, 0.2);
  -webkit-transition: -webkit-transform 300ms ease;
  transition: -webkit-transform 300ms ease;
  -o-transition: transform 300ms ease;
  transition: transform 300ms ease, -webkit-transform 300ms ease;
  -webkit-transform: translateZ(0) scale(1.02) perspective(1000px);
  transform: translateZ(0) scale(1.02) perspective(1000px);
  float: left;
}

.weather-side:hover {
  -webkit-transform: scale(1.1) perspective(1500px) rotateY(10deg);
  transform: scale(1.1) perspective(1500px) rotateY(10deg);
}

.weather-gradient {
  position: absolute;
  width: 150px;
  height: 150px;
  top: 0;
  left: 0;
  background-image: linear-gradient(135deg, #72EDF2 10%, #5151E5 100%);
  border-radius: 25px;
  opacity: 0.8;
}

.date-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 110px;
  height: 110px;
  padding: 20px;
}

.date-dayname {
  margin: 0;
}

.date-day {
  display: block;
  width: 150px;
}

.location {
  display: inline-block;
  margin-top: 2px;
  position: absolute;
  bottom: 24px;
  right: 17px;
}


.weather-container {
  position: absolute;
  bottom: 23px;
  left: 18px;
}


.weather-temp {
  margin: 0;
  font-weight: 700;
  font-size: 24px;
}

.weather-desc {
  margin: 0;
}


.today-info > div:not(:last-child) {
  margin: 0 0 10px 0;
}

</style>